import 'package:flutter/material.dart';

import '../../config/public_color.dart';
import '../../config/public_text.dart';
import 'horizontal_item.dart';

/// FileName switch_item
///
/// @Author lax
/// @Date 2023/2/22
///
/// @Description

class SwitchItem extends HorizontalItem {
  SwitchItem({
    super.key,
    super.title,
    super.enable = true,
    super.required = false,
    super.titleStyle,
    super.unableTitleStyle,
    super.unableValueStyle,
    super.titleWidth,
    super.flex,
    bool? value,
    EdgeInsets? padding,
    ValueChanged<bool>? onChanged,
  }) : super(
          padding: enable
              ? EdgeInsets.only(
                  left: (padding ?? HorizontalItem.defaultPadding)?.left ?? 0,
                  right: (padding ?? HorizontalItem.defaultPadding)?.right ?? 0)
              : padding,
          value:
              enable ? null : (value == true ? PublicText.yes : PublicText.no),
          rightWidget: enable
              ? Switch(
                  value: value == true,
                  onChanged: onChanged,
                  activeColor: PublicColor.primary,
                  materialTapTargetSize: MaterialTapTargetSize.padded,
                )
              : null,
        );
}
